const app = getApp();
const Controller = require('../controllers/controllers.js').controller;
Page({
  data: {
    type:1,
    page:1,
    pageSize:10,
    isEnd:false,
    listdata:[],
    isloading:true,
  },
  onLoad(option) {
    this.lawyerlist();
  },
  onShow(){

  },
  golink(e){
    var url=e.currentTarget.dataset.url;
    if (!wx.getStorageSync('logintoken')) {
      app.goLogin(false)
      return
    }
    wx.navigateTo({
      url:e.currentTarget.dataset.url
    });
  },
  lawyerlist(){
    var data={
      categoryId:'',
      page:this.data.page,
      pageSize:this.data.pageSize,
    }
    Controller.lawyerlist(data).then(res=>{
      if(res.data.baseData && res.data.baseData.list.length>0){
        this.setData({
          listdata:this.data.listdata.concat(res.data.baseData.list),
        })
      }
      if(res.data.baseData.lastPage){
        this.setData({
          isEnd:res.data.baseData.lastPage
        })
      }
      this.setData({
        isloading:false
      })
    }).catch(res=>{

    })
  },
  onReachBottom(){
    if(this.data.isEnd){
      return
    }else{
      this.setData({
        page:this.data.page+1
      })
      this.listForUser()
    }
    
  },
  onShareAppMessage: function (e) {
    
  },
  onShareTimeline: function(res){
    
  },

})